'''
Created on 2011-4-30

@author: mark
'''

import hashlib
import os

def hash2md5(s):
    md5 = hashlib.md5(s)
    return md5.hexdigest()

def uphotoname(s, uid):
    names = os.path.splitext(s)
    ext = names[1] if names[1] else ".jpg"
    return "user_photo_%s_%s%s" % (uid, names[0], ext)
    
def problemPhotoname(s, pid, index):
    names = os.path.splitext(s)
    return "problem_%s_photo_%s%s" % (pid, index, names[1])

        
    